﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;

namespace PSI
{
    public partial class pdf : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void proba()
        {
            //Document doc = new Document();
            //PdfWriter.GetInstance(doc, new FileStream(Request.PhysicalApplicationPath + "\\1.pdf", FileMode.Create));
            //doc.Open();
            //doc.Add(new Paragraph("Karolinka"));
            //doc.Close();
            //Response.Redirect("~/1.pdf");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            tworzTabele();
        }

        protected void tworzTabele()
        {


            BaseFont bfComic = BaseFont.CreateFont("c:\\windows\\fonts\\tahoma.ttf", BaseFont.CP1250, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font f = new iTextSharp.text.Font(bfComic, 8);

            Table tabela1 = new Table();
            tabela1.Width = 1000;
            tabela1.BorderColor = System.Drawing.Color.Black;

            TableRow wiersz = new TableRow();
            TableCell kom = new TableCell();

            String tmp = "Załącznik nr 1 do rozporządzenia Rady Ministrów z dnia .... w sprawie wniosku o wpis do ewidencji działalności gospodarczej";
            kom.Text = tmp;

            Document doc = new Document(); PdfWriter.GetInstance(doc, new FileStream(Request.PhysicalApplicationPath + "\\aaqz.pdf", FileMode.Create));
            doc.Open();


            PdfPTable table = new PdfPTable(3);
            

            PdfPCell cell = new PdfPCell(new Phrase("tabelka w pdf"));
           
            cell.Colspan = 3;

            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right

            table.AddCell(cell);

            table.AddCell("tutaj");

            table.AddCell("i tutaj");

            table.AddCell("i jeszcze tutaj");

            table.AddCell(":)");

            table.AddCell(":)");

            table.AddCell(":)");

            doc.Add(table);
            doc.Close();
            Response.Redirect("~/aaqz.pdf");

            //Chunk c = new Chunk("Some texąśćłóżźęt in Verdana \n", FontFactory.GetFont("Verdana", 12));
            //Chunk c2 = new Chunk("Moretexąśćłóżźęt text in Tahoma", FontFactory.GetFont("Times New Roman", 24));



            //iTextSharp.text.pdf.PdfPTable ta = new PdfPTable(1);
            //Paragraph p = new Paragraph(c);
            //p.Add(c2);
            //ta.AddCell(p);
            //doc.Add(ta);



        }


    }
}